package com.fq.config;

import io.swagger.annotations.ApiOperation;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Author 超chao
 * @Description TODO
 * @Date 2024/10/12/周六 13:18
 * @Version 1.0
 */
@Configuration
@EnableSwagger2
@ConfigurationProperties(prefix = "swagger")
public class SwaggerConfig {

    /**
     * 配置 Swagger 接口文档的基本信息
     * @return
     */
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                //1.接口文档标题
                .title("接口文档")
                //2.接口文档描述内容
                .description("接口文档")
                //3.项目文档迭代版本
                .version("1.0")
                //4.主要联系人信息（姓名name，个人主页url，邮箱email）
                .contact(new Contact("浮桥","","....@qq.com"))
                //5.返回构建的ApiInfo对象
                .build();
    }

    /**
     * 管理端相关接口分组
     * @return Docket
     */
    @Bean
    public Docket systemApi() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .groupName("系统模块")
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.ant("/api/sys/**"))
                .build();
    }

}
